package com.spring.shops.dao;

import com.spring.shops.model.entity.TzArea;
import com.spring.shops.model.entity.TzHotSearch;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface TzAreaMapper {
    int updateByPrimaryKey(TzArea tzArea);
    /**
     * 查询所有parant_id=0的数据
     * @param parentId
     * @return
     */
    @Select("select * from yami_shops.tz_area where parent_id=#{parentId}")
    List<TzArea> selectByParantId(Long parentId);

    /**
     * 根据城市Id查询所有的地区
     * @param id
     * @return
     */
    @Select("select * from yami_shops.tz_area where area_id=#{id}")
    TzArea selectById(Long id);

    /**
     * 列出所有的地区
     * @return
     */
    @Select("select * from yami_shops.tz_area")
    List<TzArea> selectAll();

    /**
     * 新增数据
     * @param area
     * @return
     */
    @Insert("insert into yami_shops.tz_area (area_name, parent_id, level) VALUES (" +
            "#{areaName},#{parentId},#{level})")
    int insert(TzArea area);
    /**
     * 根据id删除数据
     * @param id
     * @return
     */
    @Delete("delete from yami_shops.tz_area where area_id=#{id}")
    int deleteById(Long id);
}